package datastruct.entity;

import java.util.Vector;

public class Entity {
	private Vector<Attribute> attributeVector = new Vector<Attribute>();
	private String name;
	public Entity(String name)
	{
		this.name = name;
	}
	public void addAttribute(Attribute attribute)
	{
		this.attributeVector.add(attribute);
	}
	public Attribute[] getAttributes()
	{
		int size = this.attributeVector.size();
		Attribute[] attributes = new Attribute[size];
		for(int i=0;i<size;i++)
		{
			attributes[i] = this.attributeVector.elementAt(i);
		}
		return attributes;
	}
	public String getName()
	{
		return this.name;
	}
	public String toString()
	{
		String str = "";
		for(Attribute attribute : this.attributeVector)
		{
			str += this.name+"|"+attribute.toString()+"\n";
		}
		return str;
	}
	public int getAttributeNumber()
	{
		return this.attributeVector.size();
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public boolean containsAttribute(Attribute attribute)
	{
		for(Attribute myAttribute : this.attributeVector)
		{
			if(myAttribute.equals(attribute)) return true;
		}
		return false;
	}
	
}
